package com.immunology.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.immunology.model.MappingPages;
import com.immunology.service.ComplaintTypeService;

public class AddComplaintTypeServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public AddComplaintTypeServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		getServletContext().getRequestDispatcher(
				MappingPages.ADD_COMPLAINT_TYPE_JSP).forward(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int syndromeId = Integer.parseInt(request.getParameter("syndrome"));
		String complaintTypeName = request.getParameter("complaintName");
		double complaintMultyplier = Double.valueOf(request
				.getParameter("complaintMultyplier"));

		ComplaintTypeService complaintTypeService = ComplaintTypeService
				.getInstance();
		complaintTypeService.insert(complaintTypeName, complaintMultyplier,
				syndromeId);

		request.getRequestDispatcher(MappingPages.ADD_COMPLAINT_TYPE_JSP)
				.forward(request, response);

	}

}
